package com.yc.jpyy.mobile.service.imp;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import com.yc.jpyy.base.bean.RestResponse;
import com.yc.jpyy.base.config.Config;
import com.yc.jpyy.mobile.dao.PayDao;
import com.yc.jpyy.mobile.service.CommonService;
import com.yc.jpyy.mobile.service.PayService;

@Service
public class PayServiceImpl extends CommonService implements PayService {

	
	@Autowired
	private PayDao payDao;
	
	
	
	//缴费记录
	@Override
	public void GetStudyRecharge(Map<String, Object> paramMap,
			RestResponse response) throws DataAccessException {
		// TODO Auto-generated method stub
		List<Map<String,Object>> resultMap = null ;
		try{			
			resultMap = payDao.GetStudyRecharge(paramMap);
			if(resultMap != null){
				response.setReturnMsg(1, "缴费记录");
				response.setData(resultMap);
			}else{
				response.setReturnMsg(0, "暂无数据");
				response.setData(new ArrayList<Map<String,Object>>());
			}

		} catch (Exception e){
//			errorHandler(e, response, logger);
			System.out.println("==获取缴费记录="+ e.toString());
			response.setReturnMsg(0, "获取失败");
			response.setData(new ArrayList<Map<String,Object>>());
		}
	}

	
	
	
	//消费记录
	@Override
	public void GetCostStudyTime(Map<String, Object> paramMap,
			RestResponse response) throws DataAccessException {
		List<Map<String,Object>> resultMap = null ;
		checkPageParamsMap(paramMap);
		try{	
			
			resultMap = payDao.GetCostStudyTime(paramMap);
			
			if(resultMap != null &&  resultMap.size() > 0 ){
				for (int i = 0; i < resultMap.size() ; i++) {
					if(resultMap.get(i).get("T_Photo") != null){
						  resultMap.get(i).put("T_Photo",Config.getImageAddress()+ resultMap.get(i).get("T_Photo").toString());
					}
				}
			}
		
			
			if(resultMap != null){
				response.setReturnMsg(1, "消费记录");
				response.setData(resultMap);
			}else{
				response.setReturnMsg(0, "暂无数据");
				response.setData(new ArrayList<Map<String,Object>>());
			}
		} catch (Exception e) {
//			errorHandler(e, response, logger);
			System.out.println("==获取消费记录="+ e.toString());
			response.setReturnMsg(0, "获取失败");
			response.setData(new ArrayList<Map<String,Object>>());
		}
	}

	
	
	
	
	
	


}
